package com.learn.my.controller;

import com.learn.my.bean.User;
import com.learn.my.http.result.ResultVo;
import com.learn.my.serice.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/insert")
    public ResultVo<User> inserUser(@RequestBody User user){
        if(user==null){
            return ResultVo.createError(201,"参数错误");
        }
            if(userService.insertNewUser(user)){
                return ResultVo.createData(user);
            }else{
                return ResultVo.createError(202,"插入数据异常");
            }



    }
}
